
export const useUserStore = defineStore('user', () => {
    const router = useRouter();
    const route = useRoute();
    const token = ref(null)
    const userName = ref()
    const tokenStorage = useStorage('token')
    const userNameStorage = useStorage('userName')
    const toLogin = () => {
        router.replace({
            path: "login",
            query: {
                redirect: route.fullPath,
            },
        });
    }
    function setToken() {
        const path = route.query.redirect ?? '/'
        token.value = 'abcdefg000111'
        tokenStorage.value = token.value
        userName.value = '旺仔'
        userNameStorage.value = userName.value
        console.log(tokenStorage);
        router.replace({
            path,
        });
    }

    return { userName, token, setToken, toLogin }
})